/*计算a的n次方*/
#include <stdio.h>

int main()
{
	int a,n,i,lastthree=1;
	scanf("%d %d",&a,&n);
	for ( i=1 ; i<=n ; i++)
	{
		lastthree = lastthree * a % 1000;
	}
	if (lastthree == 0)
	{
		printf("The last 3 numbers is 000.\n");
	}
	else
	{
		printf("The last 3 numbers is %d.\n",lastthree);
	}
	return 0;
 } 
